package com.youzikj.wx.pay.hongbao;

import java.util.HashMap;
import java.util.Map;

import com.youzikj.wx.comm.util.CommonUtil;
import com.youzikj.wx.pay.MapUtil;

/**
 * 红包发送类
 * @author Administrator
 *
 */
public class PayUtil {
	
	public final static String url ="https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack";
	
	public static String sendHb(String opendid) {
		String mch_billno = MoneyUtils.getMch_billno();
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("nonce_str", MoneyUtils.buildRandom());//随机字符串
		map.put("mch_billno", mch_billno);//商户订单
		map.put("mch_id", "1419995602");//商户号
		map.put("wxappid", "wxca78deeb014de180");//商户appid
		map.put("nick_name", "柚子科技");//提供方名称
		map.put("send_name", "微友传单");//用户名
		map.put("re_openid", opendid);//用户openid
		map.put("total_amount", 100);//付款金额
		map.put("total_num", 1);//红包发送总人数
		map.put("wishing", "恭喜您已完成任务！");//红包祝福语
		map.put("client_ip", "127.0.0.1");//ip地址
		map.put("act_name", "微友传单");//活动名称
		map.put("remark", "任务多多，快来领取");//备注
		map.put("sign", MoneyUtils.createSign(map));//签名
		String result = "";
		try {
			result = MoneyUtils.doSendMoney(url, MoneyUtils.createXML(map));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("result:"+result);
		//result_code SUCCESS 代表成功
		return result;
	}
	
		
}
